package org.ihelpuoo.weboo.checkers;

import org.ihelpuoo.lang.StringUtils;

public class EmailChecker extends TextLengthChecker
{

	public EmailChecker()
	{
		super();
		setSetting(null);
	}

	@Override
	public boolean isValid(String value)
	{
		if (StringUtils.isEmpty(value))
			return true;
		if (!super.isValid(value))
			return false;
		int pos = value.indexOf('@');
		if (pos < 1 || pos == value.length() - 1)
			return false;
		return true;
	}

	@Override
	public void setSetting(String setting)
	{
		if (StringUtils.isBlank(setting) || setting.length() < 5)
			super.setSetting("[3,64]");
		else
			super.setSetting(setting);
	}

}
